home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / FWOvlShp.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  4.6 KB  |  176 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWOvlShp.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWOVLSHP_H
  13. #include "FWOvlShp.h"
  14. #endif
  15.  
  16. #ifndef SLGRGLOB_H
  17. #include "SLGrGlob.h"
  18. #endif
  19.  
  20. #ifndef FWGC_H
  21. #include "FWGC.h"
  22. #endif
  23.  
  24. #ifndef FWGRUTIL_H
  25. #include "FWGrUtil.h"
  26. #endif
  27.  
  28. #ifndef FWFXMATH_H
  29. #include "FWFxMath.h"
  30. #endif
  31.  
  32. #ifndef SLRENDER_H
  33. #include "SLRender.h"
  34. #endif
  35. // ----- Foundation Includes -----
  36.  
  37. #ifndef FWSTREAM_H
  38. #include "FWStream.h"
  39. #endif
  40.  
  41. // ----- OpenDoc Includes -----
  42.  
  43. #ifndef SOM_ODTransform_xh
  44. #include <Trnsform.xh>
  45. #endif
  46.  
  47. //========================================================================================
  48. //    RunTime Info
  49. //========================================================================================
  50.  
  51. #ifdef FW_BUILD_MAC
  52. #pragma segment FWGraphics_OvalShape
  53. #endif
  54.  
  55. FW_DEFINE_AUTO(FW_COvalShape)
  56. FW_DEFINE_CLASS_M1(FW_COvalShape, FW_CBoundedShape)
  57.  
  58. //========================================================================================
  59. //    class FW_COvalShape
  60. //========================================================================================
  61.  
  62. //----------------------------------------------------------------------------------------
  63. //    FW_COvalShape::FW_COvalShape
  64. //----------------------------------------------------------------------------------------
  65.  
  66. FW_COvalShape::FW_COvalShape(const FW_COvalShape& other) :
  67.     FW_CBoundedShape(other)
  68. {
  69.     FW_END_CONSTRUCTOR
  70. }
  71.  
  72. //----------------------------------------------------------------------------------------
  73. //    FW_COvalShape::FW_COvalShape
  74. //----------------------------------------------------------------------------------------
  75.  
  76. FW_COvalShape::FW_COvalShape(const FW_CRect& rect,
  77.                              FW_ERenderVerbs renderVerb,
  78.                              const FW_CInk& ink,
  79.                              const FW_CStyle& style) :
  80.     FW_CBoundedShape(rect, renderVerb, ink, style, FW_kNormalFont)
  81. {
  82.     FW_END_CONSTRUCTOR
  83. }
  84.  
  85. //----------------------------------------------------------------------------------------
  86. //    FW_COvalShape::FW_COvalShape
  87. //----------------------------------------------------------------------------------------
  88.  
  89. FW_COvalShape::FW_COvalShape(FW_CReadableStream& stream) :
  90.     FW_CBoundedShape(stream)
  91. {
  92.     FW_END_CONSTRUCTOR
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. //    FW_COvalShape::~FW_COvalShape
  97. //----------------------------------------------------------------------------------------
  98.  
  99. FW_COvalShape::~FW_COvalShape()
  100. {
  101.     FW_START_DESTRUCTOR
  102. }
  103.  
  104. //----------------------------------------------------------------------------------------
  105. //    FW_COvalShape::Render
  106. //----------------------------------------------------------------------------------------
  107.  
  108. void FW_COvalShape::Render(FW_CGraphicContext& gc) const
  109. {    
  110.     FW_PrivRenderOval(gc.GetEnvironment(),
  111.         gc,
  112.         fRect,
  113.         GetRenderVerb(),
  114.         fInk,
  115.         fStyle);
  116.     FW_FailOnEvError(gc.GetEnvironment());
  117. }
  118.  
  119. //----------------------------------------------------------------------------------------
  120. //    FW_COvalShape::RenderOval
  121. //----------------------------------------------------------------------------------------
  122.  
  123. void FW_COvalShape::RenderOval(FW_CGraphicContext& gc,
  124.                                 const FW_CRect& rect, 
  125.                                 FW_ERenderVerbs renderVerb, 
  126.                                 const FW_CInk& ink,
  127.                                 const FW_CStyle& style)
  128. {    
  129.     FW_PrivRenderOval(gc.GetEnvironment(),
  130.         gc,
  131.         rect,
  132.         renderVerb,
  133.         ink,
  134.         style);
  135.     FW_FailOnEvError(gc.GetEnvironment());
  136. }
  137.  
  138. //----------------------------------------------------------------------------------------
  139. //    FW_COvalShape::HitTest
  140. //----------------------------------------------------------------------------------------
  141.  
  142. FW_Boolean FW_COvalShape::HitTest(FW_CGraphicContext& gc,
  143.                                   const FW_CPoint& test,
  144.                                   FW_Fixed tolerance) const
  145. {
  146. FW_UNUSED(gc);
  147.     if(fRenderVerb == FW_kNoRendering)
  148.         return FALSE;
  149.  
  150.     FW_CRect ovalRect(fRect);
  151.     ovalRect.Inset(-tolerance, -tolerance);
  152.     
  153.     if (!::FW_PtInOval(ovalRect, test))
  154.         return FALSE;
  155.     
  156.     if (fRenderVerb == FW_kFrame)
  157.     {
  158.         ovalRect = fRect;
  159.         FW_Fixed inset = tolerance + GetPenSize();
  160.         ovalRect.Inset(inset, inset);
  161.         return ! ::FW_PtInOval(ovalRect, test);
  162.     }
  163.     
  164.     return TRUE;
  165. }
  166.  
  167. //----------------------------------------------------------------------------------------
  168. //    FW_COvalShape::Copy
  169. //----------------------------------------------------------------------------------------
  170.  
  171. FW_CShape* FW_COvalShape::Copy() const
  172. {
  173.     return FW_NEW(FW_COvalShape, (*this));
  174. }
  175.  
  176.